package com.alpha.bom;

import java.util.ArrayList;

/**
 * 
 * This class is is used to create an exam.
 * 
 * @author Catherine C. Graza
 * @version 1.0
 * @since JDK1.7
 */
public abstract class Exam {

	private int examId;
	private String examName;
	private String examType;
	private ArrayList<Question> questions;
	private int professorId;
	private String category;
	
	/**
	 * This is used to get the professor ID.
	 * @return the professorId
	 */
	public int getProfessorId() {
		return professorId;
	}

	/**
	 * This is used to set the professor ID.
	 * @param professorId the professorId to set
	 */
	public void setProfessorId(int professorId) {
		this.professorId = professorId;
	}
	
	
	/**
	 * This is used to get the exam id
	 * @return integer type of id
	 */
	public int getExamId() {
		return examId;
	}

	/**
	 * This is used to change the value of the exam id to the specified id
	 * @param examId the specified integer value of the exam id
	 */
	public void setExamId(int examId) {
		this.examId = examId;
	}
	
	/**
	 * This is used to retrieve the exam name
	 * @return String the name of the exam
	 */
	public String getExamName() {
		return examName;
	}
	
	/**
	 * This is used to change the exam name
	 * @param examName the specified exam name
	 */
	public void setExamName(String examName) {
		this.examName = examName;
	}
	
	/**
	 * This is used to retrieve the exam type
	 * @return String indicate the exam type
	 */
	public String getExamType() {
		return examType;
	}
	
	/**
	 * This is used to change the exam type
	 * @param examType String that specifies the exam type
	 */
	public void setExamType(String examType) {
		this.examType = examType;
	}
	
	/**
	 * This is used to retrieve the questions of the exam.
	 * @return ArrayList<Questions> array of questions
	 */
	public ArrayList<Question> getQuestions() {
		return questions;
	}
	
	/**
	 * This is used to change the questions of the exam.
	 * @param questions These are the questions for the exam
	 */
	public void setQuestions(ArrayList<Question> questions) {
		this.questions = questions;
	}
	
	/**
	 * This is used to retrieve the category of the exam.
	 * @return the category
	 */
	public String getCategory() {
		return category;
	}

	/**
	 *  This is used to set the category of the exam.
	 * @param category the category to set
	 */
	public void setCategory(String category) {
		this.category = category;
	}

	/**
	 * @param question
	 * @return boolean
	 * true, if the question has been added to the exam
	 * false, if the question was not added to the exam
	 */
	public boolean addQuestion(Question question){
		boolean added = false;
		int index = this.questions.indexOf(question);
		if(index==-1){
			questions.add(question);
			added = true;
		}
		return added;
	}

	

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return "Exam [examId=" + examId + ", examName=" + examName
				+ ", examType=" + examType + ", questions=" + questions
				+ "]";
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#hashCode()
	 */
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + examId;
		return result;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Exam other = (Exam) obj;
		if (examId != other.examId)
			return false;
		return true;
	}
}
